package com.aaa.newpeculiarity8.demo03;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: 自定义有参有返回值的函数式接口
 * @date 2022/11/3
 */
public class Test01 {
    public static void main(String[] args) {
        //无需参数类型
        Operator o=(arr)->{
          int sum=0;
            for (int i : arr) {
                sum+=i;
            }
            return sum;
        };
        fan(o);
    }
    public static void fan(Operator operator){
        int sum[] = {24,35,56,68};
        int sum1 = operator.sueForPeace(sum);
        System.out.println("数组中元素的和:"+sum1);
    }
}
interface Operator{
    //求数组中元素的和
    public int sueForPeace(int[] arr);
}